import * as ElementPlusIconsVue from '@element-plus/icons-vue'

export default defineComponent({
  name: 'StringToSub',
  props: {
    icon_class: {
      type: String,
      require: true
    }
  },
  setup(props: { icon_class: string | undefined }) {
    const get_ele_icon = computed(() => {
      const ele_icons = Object.entries(ElementPlusIconsVue).map(item => item[1])
      const getIcon = ele_icons.find(item => item.name === props.icon_class)
      if (getIcon) {
        return getIcon.render && getIcon.render()
      }
    })

    return () => h(get_ele_icon.value)
  }
})
